<p>
  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
    <input name="host" value="<?php echo $_REQUEST['host']; ?>" />
    <input type="submit" value="Set host" />
   <span id="connectionText"></span>
  </form>
   <script type="text/javascript">
   function setConnectionText(s) {
     $("connectionText").innerHTML = s;
   }
   function setConnectionTextConnected() {
     setConnectionText("Connected");
   }
   function setConnectionTextDisconnected() {
     setConnectionText("Disconnected");
   }
   function setConnectionTextConnecting() {
     setConnectionText("Connecting");
   }
</script>
  <?php
   if (isset($_SESSION['host'])) {
     echo '<script type="text/javascript">';
     echo 'setConnectionTextConnecting();';
     echo 'setHost("' . $_SESSION['host'] . '");';
     echo 'setConnectionTextConnected();';
     echo '</script>';
     } else if (isset($_REQUEST['host'])) {
     $_SESSION['host'] = $_REQUEST['host'];
     echo '<script type="text/javascript">';
     echo 'setConnectionTextConnecting();';
     echo 'setHost("' . $_REQUEST['host'] . '");';
     echo 'setConnectionTextConnected();';
     echo '</script>';
   }  else {
     echo '<script type="text/javascript">';
     echo 'setConnectionTextDisconnected();';
     echo '</script>';
   }
     ?>
</p>
